<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>气球</title>
    <style>
        html, body, #container {
            margin: 0; padding: 0; width: 100%; height: 100%;
        }
    </style>
</head>
<body>
<div id="container"></div>
<script src="https://webapi.amap.com/maps?v=1.4.14&key=deb3984a051e88ac44477bdbb145a9ca&plugin=Map3D,AMap.DistrictSearch"></script>
<script>
    // 初始化地图
    var map = new AMap.Map('container', {
        viewMode: '3D',
        defaultCursor: 'pointer',
        expandZoomRange: true,
        zooms: [3, 20],
        pitch: 50,
        zoom: 4.8,
        center: [109, 32]
    });
    // 3D
    var object3Dlayer = new AMap.Object3DLayer({ zIndex: 110, opacity: 1 });
    map.add(object3Dlayer);

    function lnglatToG20(lnglat) {
        lnglat = map.lngLatToGeodeticCoord(lnglat);
        lnglat.x = AMap.Util.format(lnglat.x, 3);
        lnglat.y = AMap.Util.format(lnglat.y, 3);
        return lnglat;
    }

    var lines = new AMap.Object3D.Line();
    var lineGeo = lines.geometry;

    new AMap.DistrictSearch({
        subdistrict: 1,   //返回下一级行政区
        extensions: 'base'
    }).search('中国', function (status, result) {
        var provinces = result.districtList[0].districtList;
        var points3D = new AMap.Object3D.RoundPoints();
        points3D.transparent = true;
        var pointsGeo = points3D.geometry;
        for (var p = 0; p < provinces.length; p += 1) {
            var center = lnglatToG20(provinces[p].center);
            var size = Math.max(10, Math.round(Math.random() * 40));
            var height = -size * 10000;

            // 连线
            lineGeo.vertices.push(center.x, center.y, 0);
            lineGeo.vertexColors.push(0, 1, 1, 1);
            lineGeo.vertices.push(center.x, center.y, height);
            lineGeo.vertexColors.push(0, 1, 1, 1);

            pointsGeo.vertices.push(center.x, center.y, 0); // 尾部小点
            pointsGeo.pointSizes.push(5);
            pointsGeo.vertexColors.push(0, 0, 1, 1);

            pointsGeo.vertices.push(center.x, center.y, height); // 空中点
            pointsGeo.pointSizes.push(size);
            pointsGeo.vertexColors.push(p * 0.029, p * 0.015, p * 0.01, 1);
        }

        points3D.borderColor = [0.4, 0.8, 1, 1];
        points3D.borderWeight = 3;
        object3Dlayer.add(lines);
        object3Dlayer.add(points3D);
    });
    map.on('mousemove',function(ev){
        var pixel = ev.pixel;
        var px = new AMap.Pixel(pixel.x, pixel.y);
        var obj = map.getObject3DByContainerPos(px, [object3Dlayer], false) || {};
        console.log(obj)
    })
</script>
</body>
</html>